/**
 * 
 */
package com.nexttwist;

import java.util.List;

import android.app.Dialog;
import android.support.v4.app.Fragment;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

import com.nexttwist.adapters.DashboardAdapter;
import com.nexttwist.dao.TrackDAO;
import com.nexttwist.model.SampleTrack;

/**
 * @author HarishKumarG
 *
 */
public class MyRecoringsFragment extends Fragment {
	
	//private View mView;
		private ListView mListView;
		
		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View mView = inflater.inflate(R.layout.fragment_dashboard, container, false);
			
			mListView = (ListView) mView.findViewById(R.id.list_of_records);
			DashboardAdapter mAdapter = new DashboardAdapter(getActivity().getApplicationContext(), getDummyData());
			mListView.setAdapter(mAdapter);
			mListView.setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
					Toast.makeText(getActivity().getApplicationContext(),"Click ListItem Number " + position, Toast.LENGTH_LONG).show();
					showCustomDialog();
				}
			});
			
			return mView;
		}
		
		
		private List<SampleTrack> getDummyData() {
			TrackDAO mTrackDAO = new TrackDAO(getActivity());
			mTrackDAO.open();
			return mTrackDAO.getAllTracks();
		}
		

		private void showCustomDialog() {
	        final Dialog dialog = new Dialog(getActivity());
	        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	        dialog.setContentView(R.layout.activity_track_detail);
	        
	        dialog.show();
	    }

}
